import networkx as nx
import pickle, os, sys
import numpy as np

def build_graph(N, type):
    if type == "cycle":
        G = nx.cycle_graph(N)
    elif type == "complete":
        G = nx.complete_graph(N)
    elif type == "random":
        G = nx.erdos_renyi_graph(N, 0.5, seed=514, directed=False)
    print(f"Start graph files creation with N = {N} and type = {type}")
    for i in range(N):
        print(G.adj[i])
        os.makedirs(os.path.dirname(f"Graph/N={N}/{type}/neighbor_of_{i}.txt"), exist_ok=True)
        np.savetxt(f"Graph/N={N}/{type}/neighbor_of_{i}.txt", G.adj[i], fmt='%.8f', delimiter=',')

if __name__ == "__main__":
    for i in range(5):
        for j in ["cycle", "complete", "random"]:
           number_of_nodes = i+1
           graph_type = j
           build_graph(number_of_nodes, graph_type)
